Trò chơi Tic-Tac-Toe, game đánh caro full source code
53.576 lượt xem;
- ServerSettings.cs
- PhotonNetwork /
- Plugins /
- Photon Unity Networking /
- Assets /
- project /
1 #pragma warning disable 1587
2 /// \file
3 /// <summary>ScriptableObject defining a server setup. An instance is created as <b>PhotonServerSettings</b>.</summary>
4 #pragma warning restore 1587
5
6
7 using System;
8 using System.Collections.Generic;
9 using ExitGames.Client.Photon;
10 using UnityEngine;
11
12
13 public class Region
14 {
15 public CloudRegionCode Code;
16 public string HostAndPort;
17 public int Ping;
18
19 public static CloudRegionCode Parse(string codeAsString)
20 {
21 codeAsString = codeAsString.ToLower();
22
23 CloudRegionCode code = CloudRegionCode.none;
24 if (Enum.IsDefined(typeof(CloudRegionCode), codeAsString))
25 {
26 code = (CloudRegionCode)Enum.Parse(typeof(CloudRegionCode), codeAsString);
27 }
28
29 return code;
30 }
31
32 public override string ToString()
33 {
34 return string.Format("'{0}' \t{1}ms \t{2}", this.Code, this.Ping, this.HostAndPort);
35 }
36 }
37
38
39 /// <summary>
40 /// Collection of connection-relevant settings, used internally by PhotonNetwork.ConnectUsingSettings.
41 /// </summary>
42 [Serializable]
43 public class ServerSettings : ScriptableObject
44 {
45 public enum HostingOption { NotSet, PhotonCloud, SelfHosted, OfflineMode, BestRegion }
46 public HostingOption HostType = HostingOption.NotSet;
47 public ConnectionProtocol Protocol = ConnectionProtocol.Udp;
48
49 // custom server values (not used for PhotonCloud)
50 public string ServerAddress = ""; // the address to be used (including region-suffix)
51 public int ServerPort = 5055;
52
53 public CloudRegionCode PreferredRegion;
54 public string AppID = "";
55 public bool PingCloudServersOnAwake = false;
56
57 public List<string> RpcList = new List<string>(); // set by scripts and or via Inspector
58
59 [HideInInspector]
60 public bool DisableAutoOpenWizard;
61
62
63 public void UseCloudBestResion(string cloudAppid)
64 {
65 this.HostType = HostingOption.BestRegion;
66 this.AppID = cloudAppid;
67 }
68
69 public void UseCloud(string cloudAppid)
70 {
71 this.HostType = HostingOption.PhotonCloud;
72 this.AppID = cloudAppid;
73 }
74
75 public void UseCloud(string cloudAppid, CloudRegionCode code)
76 {
77 this.HostType = HostingOption.PhotonCloud;
78 this.AppID = cloudAppid;
79 this.PreferredRegion = code;
80 }
81
82 public void UseMyServer(string serverAddress, int serverPort, string application)
83 {
84 this.HostType = HostingOption.SelfHosted;
85 this.AppID = (application != null) ? application : "master";
86
87 this.ServerAddress = serverAddress;
88 this.ServerPort = serverPort;
89 }
90
91 public override string ToString()
92 {
93 return "ServerSettings: " + HostType + " " + ServerAddress;
94 }
95 }
2 /// \file
3 /// <summary>ScriptableObject defining a server setup. An instance is created as <b>PhotonServerSettings</b>.</summary>
4 #pragma warning restore 1587
5
6
7 using System;
8 using System.Collections.Generic;
9 using ExitGames.Client.Photon;
10 using UnityEngine;
11
12
13 public class Region
14 {
15 public CloudRegionCode Code;
16 public string HostAndPort;
17 public int Ping;
18
19 public static CloudRegionCode Parse(string codeAsString)
20 {
21 codeAsString = codeAsString.ToLower();
22
23 CloudRegionCode code = CloudRegionCode.none;
24 if (Enum.IsDefined(typeof(CloudRegionCode), codeAsString))
25 {
26 code = (CloudRegionCode)Enum.Parse(typeof(CloudRegionCode), codeAsString);
27 }
28
29 return code;
30 }
31
32 public override string ToString()
33 {
34 return string.Format("'{0}' \t{1}ms \t{2}", this.Code, this.Ping, this.HostAndPort);
35 }
36 }
37
38
39 /// <summary>
40 /// Collection of connection-relevant settings, used internally by PhotonNetwork.ConnectUsingSettings.
41 /// </summary>
42 [Serializable]
43 public class ServerSettings : ScriptableObject
44 {
45 public enum HostingOption { NotSet, PhotonCloud, SelfHosted, OfflineMode, BestRegion }
46 public HostingOption HostType = HostingOption.NotSet;
47 public ConnectionProtocol Protocol = ConnectionProtocol.Udp;
48
49 // custom server values (not used for PhotonCloud)
50 public string ServerAddress = ""; // the address to be used (including region-suffix)
51 public int ServerPort = 5055;
52
53 public CloudRegionCode PreferredRegion;
54 public string AppID = "";
55 public bool PingCloudServersOnAwake = false;
56
57 public List<string> RpcList = new List<string>(); // set by scripts and or via Inspector
58
59 [HideInInspector]
60 public bool DisableAutoOpenWizard;
61
62
63 public void UseCloudBestResion(string cloudAppid)
64 {
65 this.HostType = HostingOption.BestRegion;
66 this.AppID = cloudAppid;
67 }
68
69 public void UseCloud(string cloudAppid)
70 {
71 this.HostType = HostingOption.PhotonCloud;
72 this.AppID = cloudAppid;
73 }
74
75 public void UseCloud(string cloudAppid, CloudRegionCode code)
76 {
77 this.HostType = HostingOption.PhotonCloud;
78 this.AppID = cloudAppid;
79 this.PreferredRegion = code;
80 }
81
82 public void UseMyServer(string serverAddress, int serverPort, string application)
83 {
84 this.HostType = HostingOption.SelfHosted;
85 this.AppID = (application != null) ? application : "master";
86
87 this.ServerAddress = serverAddress;
88 this.ServerPort = serverPort;
89 }
90
91 public override string ToString()
92 {
93 return "ServerSettings: " + HostType + " " + ServerAddress;
94 }
95 }
\file
Collection of connection-relevant settings, used internally by PhotonNetwork.ConnectUsingSettings.
custom server values (not used for PhotonCloud)
public string ServerAddress = ""; the address to be used (including region-suffix)
public List